package runze.shiro.exception;

import org.apache.shiro.authz.AuthorizationException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author wrzhxy@qq.com
 * @date 2018年1月2日
 */
@ControllerAdvice
@ResponseBody
public class ExceptionHandlerAdvice {
	@ExceptionHandler(AuthorizationException.class)
//	@ResponseStatus(HttpStatus.FORBIDDEN)
	public String handleException(AuthorizationException e) {

      // you could return a 404 here instead (this is how github handles 403, so the user does NOT know there is a
      // resource at that location)
System.out.println("AuthorizationException was thrown");

//      Map<String, Object> map = new HashMap<String, Object>();
//      map.put("status", HttpStatus.FORBIDDEN.value());
//      map.put("message", "No message available");
//      model.addAttribute("errors", map);

		return "403";
	}
}
